import getAppEasyInfo from '@deepfos/help/es/app/appInfo';
import { getSpaceLanguage } from '@deepfos/help/es/language';
import { i18n } from '@lingui/core';
import antdEnUS from 'antd/es/locale/en_US';
import antdZhCN from 'antd/es/locale/zh_CN';

export const locales = {
  'zh-cn': {
    antd: antdZhCN,
  },
  en: {
    antd: antdEnUS,
  },
};

export async function dynamicActivate(locale: string) {
  const { messages } = await import(`./locales/${locale}/messages.ts`);
  i18n.load(locale, messages);
  i18n.activate(locale);
}

export const defaultLocale = getSpaceLanguage(getAppEasyInfo().space);

await dynamicActivate(defaultLocale);
